/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.registration.gui.security;

import it.polimi.registration.business.security.boundary.UserManager;
import it.polimi.registration.business.security.entity.User;
import javax.ejb.Stateless;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;

/**
 *
 * @author Stefano
 */
@Named
@RequestScoped
public class SettingsBean {
    
    @Inject
    private UserManager um;
    
    private User user;
    private boolean saved = false;

    public SettingsBean() {
    }

    public User getUser() {
        if (user == null) {
            user = um.getLoggedUser();
        }
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
    
    public void save(){
        um.update(user);
        this.saved = true;
    }
    
    public boolean getSaved(){
        return saved;
    }
}
